<? if ($c = stack('name')) {

	$d = component_data($c); 
	$s = component_settings($c);
	
	
//debug($s);	
//debug($d);	

startScript('jquery'); ?><script type="text/javascript">jQuery(function($){
$("#year").change(function(){
	location.href = "<?=_transformURL($CURRENT->url, array('remove_param' => 'year'))?>/year-" + $(this).find("option:selected").val();
});
});</script><? endScript(); ?>

<div class="projects">
	<div class="form">
		 <div class="year">
			<label for="year"><?=tc('Выберите год')?></label>
			  <select name="year" id="year"><? 
					if (is_array($d['years'])) foreach($d['years'] as $v) {
						?><option value="<?=h($v)?>" <?=($v == $d['year']) ? 'selected' : ''?>><?=$v?></option><?
					}
			  ?></select>
		 </div>
		 <div class="all">
			  <label><input type="checkbox" name="all" id="all" checked="checked" /> <span><?=tc('Все')?></span></label>
		 </div>

<? if (is_array($dx['categories'])) {
		foreach($dx['categories'] as $v) {
			?><div class="<?=h($v['title'])?>">
				<label><input type="checkbox" name="<?=h($v['title'])?>" id="<?=h($v['title'])?>" checked="checked" /> <span><?=h($v['value'])?></span></label>
			</div><?
		}
	}
?>
	</div>
	<a href="#" class="button button-left"><img src="/img/button_left.png" alt=""/> <?=tc('Ранее')?></a>
	<a href="#" class="button button-right"><?=tc('Позднее')?> <img src="/img/button_right.png" alt=""/></a>
	
<?
//debug($d);
?>	
	
	<div class="wrapper">
		 <div class="wrapper-inner">
			  <table id="projects" cellspacing="1">
					<tfoot>
						 <tr><?
						 	foreach($d['months'] as $v) {
							  ?><th><?=tc($v)?></th><?
							}
						 ?></tr>
					</tfoot>
					<tbody><?
					
					
for($row = 1; $row <= $d['rows']; $row++) {
	?><tr><?

	for($col = 1; $col <= $d['cols']; $col++) {

		$class = array();
		if (($col == 6) || ($col == 12)) $class[] = 'last';

		if ($row > $d['rows'] - count($d['m'][$col])) {	// filled cell
			$p = array_shift($d['m'][$col]);
			
			$class[] = $dx['categories'][$p['cat']]['name'];
			
			?><td class="<?=implode(' ', $class)?>">
				<a href="<?=$p['id']?>/">
				<img src="<?=$p['image']['fn']?>" alt="<?=h($p['title'])?>" width="<?=$p['image']['x']?>" height="<?=$p['image']['y']?>"/>
				<span><?=$p['title']?><br /><span class="more"><?=tc('далее')?> <img src="/img/arrow_small.png" alt=""/> </span></span>
				<b class="border col-<?=$dx['categories'][$p['cat']]['id_index']?>"></b>
				</a>
			</td><?
			
		} else {	?><td class="<?=implode(' ', $class)?>">&nbsp;</td><?	}	// empty cell
	}

	?></tr><?
} 
					
					?></tbody>
			  </table>
		 </div>
	</div>
</div>
<?

}

unstack();